package com.mercury.ec.module.air.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import com.mercury.ec.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 机票订单退票订单类型枚举
 *
 * @author hesx
 */
@Getter
@AllArgsConstructor
public enum AirOrderReturnOrderTypeEnum implements IntArrayValuable {

    RETURN(1, "退票"),
    VOID(2, "废票"),
    ;


    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AirOrderReturnOrderTypeEnum::getType).toArray();

    public static final String DICT_TYPE = "air_order_return_order_type";

    /**
     * 值
     */
    private final Integer type;
    /**
     * 名称
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static AirOrderReturnOrderTypeEnum getByType(int type) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(type), values());
    }

    public static boolean isReturn(Integer type) {
        return ObjUtil.equal(RETURN.type, type);
    }

    public static boolean isVoid(Integer type) {
        return ObjUtil.equal(VOID.type, type);
    }
}
